package com.zhixing.reward.controller;

import com.zhixing.common.annotation.Driver;
import com.zhixing.common.utils.Res;
import com.zhixing.common.utils.UserContext;
import com.zhixing.reward.domain.vo.RewardVO;
import com.zhixing.reward.service.RewardService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * 奖励接口
 */
@Slf4j
@RestController
@RequestMapping("/reward")
@RequiredArgsConstructor
public class RewardController {

    private final RewardService rewardService;

    /**
     * 获取奖励信息
     * @return List<RewardVO> 奖励信息
     */
    @Driver
    @GetMapping
    public Res<List<RewardVO>> getRewardInfo() {
        Integer userId = UserContext.getUserInfo().getId();
        log.info("奖励服务调用，获取奖励，用户id：{}", userId);
        return Res.ok(rewardService.getRewardInfo(userId));
    }
}
